<template>
  <div class="app-container">
    <el-form :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      class="form-search"
      label-width="130px">
      <el-form-item :label="$t('FAExhg.bankName')"
        prop="bankName">
        <el-select v-model="queryParams.bankId"
          clearable
          :placeholder="$t('common.placeholderSelect')"
          style="width: 240px">
          <el-option v-for="item in bankList"
            :key="item.bankId"
            :label="item.bankName"
            :value="item.bankId">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('fundAtp.ifscCode')"
        prop="ifscCode">
        <el-input v-model="queryParams.ifscCode"
          :placeholder="$t('common.placeholderContent')"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item :label="$t('fundAtp.status')"
        prop="status">
        <el-select v-model="queryParams.status"
          :placeholder="$t('common.placeholderSelect')"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 240px">
          <el-option v-for="dict in dict.type.bank_account_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('fundAtp.auditStatus')"
        prop="auditStatus">
        <el-select v-model="queryParams.auditStatus"
          :placeholder="$t('common.placeholderSelect')"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 240px">
          <el-option v-for="dict in dict.type.audit_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('fundAtp.accountName')"
        prop="accountName">
        <el-input v-model="queryParams.accountName"
          :placeholder="$t('common.placeholderContent')"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item :label="$t('fundAtp.accountNumber')"
        prop="accountNumber">
        <el-input v-model="queryParams.accountNumber"
          :placeholder="$t('common.placeholderContent')"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item :label="$t('fundAtp.companyName')"
        prop="companyName">
        <el-input v-model="queryParams.companyName"
          :placeholder="$t('common.placeholderContent')"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item :label="$t('fundAtp.mobileNumber')"
        prop="mobileNumber">
        <el-input v-model="queryParams.mobileNumber"
          :placeholder="$t('common.placeholderContent')"
          clearable
          style="width: 240px"
          maxlength="50"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery">{{$t('common.search')}}</el-button>
        <el-button icon="el-icon-refresh"
          size="mini"
          @click="resetQuery">{{$t('common.reset')}}</el-button>
      </el-form-item>
    </el-form>

    <div class="section-box">
      <el-row :gutter="10"
        class="mb8">
        <el-col :span="1.5">
          <el-button type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd">{{$t('common.add')}}</el-button>
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate">{{$t('common.edit')}}</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete">{{$t('common.delete')}}</el-button>
        </el-col> -->
        <right-toolbar :showSearch.sync="showSearch"
          @queryTable="getList"></right-toolbar>
      </el-row>

      <el-table v-loading="loading"
        :data="accountList">
        <!-- <el-table-column type="selection"
          width="55"
          align="center" /> -->
        <el-table-column :label="$t('fundAtp.accountName')"
          align="center"
          prop="accountName"
          min-width="160"
          show-overflow-tooltip />
        <el-table-column :label="$t('fundAtp.accountNumber')"
          align="center"
          prop="accountNumber"
          min-width="160"
          show-overflow-tooltip />
        <el-table-column :label="$t('fundAtp.mobileNumber')"
          align="center"
          prop="mobileNumber"
          min-width="160"
          show-overflow-tooltip />
        <el-table-column :label="$t('fundAtp.bankName')"
          align="center"
          prop="bankName"
          min-width="160"
          show-overflow-tooltip />
        <el-table-column :label="$t('fundAtp.modeType')"
          align="center"
          prop="modeType"
          min-width="140">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_card_mode_type"
              :value="scope.row.modeType" />
          </template>
        </el-table-column>
        <el-table-column :label="$t('fundAtp.totalAmount')"
          align="center"
          prop="totalAmount"
          min-width="120" />
        <el-table-column :label="$t('fundAtp.singleAmount')"
          align="center"
          prop="singleAmount"
          min-width="120" />
        <el-table-column :label="$t('fundAtp.safeAmount')"
          align="center"
          prop="safeAmount"
          min-width="120" />
        <el-table-column :label="$t('fundAtp.companyName')"
          align="center"
          prop="companyName"
          min-width="160"
          show-overflow-tooltip />
        <el-table-column :label="$t('fundAtp.status')"
          align="center"
          min-width="100">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.status"
              v-if="scope.row.status != '2'"
              active-value="1"
              inactive-value="0"
              @change="handleStatusChange(scope.row)"></el-switch>
            <dict-tag v-else
              :options="dict.type.bank_account_status"
              :value="scope.row.status" />
          </template>
        </el-table-column>
        <el-table-column :label="$t('fundAtp.auditStatus')"
          align="center"
          prop="auditStatus"
          min-width="120">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.audit_status"
              :value="scope.row.auditStatus" />
          </template>
        </el-table-column>

        <el-table-column :label="$t('common.createBy')"
          align="center"
          prop="createBy"
          min-width="140"
          show-overflow-tooltip />
        <el-table-column :label="$t('common.createTime')"
          align="center"
          prop="createTime"
          min-width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('common.updateBy')"
          align="center"
          prop="updateBy"
          min-width="140"
          show-overflow-tooltip />
        <el-table-column :label="$t('common.updateTime')"
          align="center"
          prop="updateTime"
          min-width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('common.remark')"
          prop="remark"
          min-width="160"
          show-overflow-tooltip />
        <el-table-column :label="$t('common.controls')"
          align="center"
          class-name="small-padding fixed-width"
          fixed="right"
          min-width="180">
          <template slot-scope="scope">
            <!-- <el-button size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleView(scope.row)">{{$t('common.view')}}</el-button> -->
            <!-- <el-button size="mini"
              type="text"
              icon="el-icon-check"
              v-if="scope.row.auditStatus == '0' || scope.row.auditStatus == '2'"
              @click="handleUpdateAuditStatus(scope.row)">{{scope.row.auditStatus == '0'?  $t('fundAtp.submitAudit'): $t('fundAtp.withdrawAudit')}}</el-button>
            <el-button size="mini"
              type="text"
              icon="el-icon-check"
              @click="handleSysAudit(scope.row)">{{$t('fundAtp.audit')}}</el-button> -->
            <template v-if="scope.row.auditStatus != '1'">
              <el-button size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)">{{$t('common.edit')}}</el-button>
              <el-button size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)">{{$t('common.delete')}}</el-button>
              <el-dropdown size="mini"
                @command="(command) => handleCommand(command, scope.row)">
                <el-button size="mini"
                  type="text"
                  icon="el-icon-d-arrow-right">{{$t('common.more')}}</el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handleView"
                    icon="el-icon-view">{{$t('common.view')}}</el-dropdown-item>

                  <el-dropdown-item command="handleUpdateAuditStatus"
                    v-if="scope.row.auditStatus == '0' || scope.row.auditStatus == '-1' || scope.row.auditStatus == '2'"
                    icon="el-icon-circle-check">
                    {{(scope.row.auditStatus == '0' || scope.row.auditStatus == '-1') ? $t('fundAtp.submitAudit'): $t('fundAtp.withdrawAudit')}}
                  </el-dropdown-item>

                  <el-dropdown-item command="handleSysAudit"
                    v-if="scope.row.auditStatus == '2' && userInfo.exchangeId == 0"
                    icon="el-icon-check">{{$t('fundAtp.audit')}}</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
            <el-button size="mini"
              v-else
              type="text"
              icon="el-icon-view"
              @click="handleView(scope.row)">{{$t('common.view')}}</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>

    <!-- 查详情 -->
    <ViewShow :title="$t('fundAtp.bankAccountInfo')"
      :open="showView"
      :dataList="viewList"
      :isLine="true"
      :labelWidth="180"
      width="800"
      @toClose="showView = false" />

    <!-- 添加或修改对话框 -->
    <el-dialog :title="title"
      :visible.sync="open"
      width="1050px"
      append-to-body>
      <el-form ref="form"
        :model="form"
        :rules="rules"
        label-width="180px"
        class="form-box">
        <el-form-item :label="$t('fundAtp.bankName')"
          prop="bankId"
          class="item-form">
          <el-select v-model="form.bankId"
            clearable
            :placeholder="$t('common.placeholderSelect')"
            style="width: 100%">
            <el-option v-for="item in bankList"
              :key="item.bankId"
              :label="item.bankName"
              :value="item.bankId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.accountName')"
          prop="accountName"
          class="item-form">
          <el-input v-model="form.accountName"
            maxlength="100"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.accountNumber')"
          prop="accountNumber"
          class="item-form">
          <el-input v-model="form.accountNumber"
            maxlength="50"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.ifscCode')"
          prop="ifscCode"
          class="item-form">
          <el-input v-model="form.ifscCode"
            maxlength="20"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.modeType')"
          prop="modeType"
          class="item-form">
          <el-select v-model="form.modeType"
            :placeholder="$t('common.placeholderSelect')"
            clearable
            style="width: 100%">
            <el-option v-for="dict in dict.type.sys_card_mode_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.totalAmount')"
          prop="totalAmount"
          class="item-form">
          <el-input v-model="form.totalAmount"
            maxlength="15"
            @input="form.totalAmount = onInput(form.totalAmount)"
            :placeholder="$t('common.placeholderContent')">
            <template slot="append">{{$t('common.unit')}}</template>
          </el-input>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.singleAmount')"
          prop="singleAmount"
          class="item-form">
          <el-input v-model="form.singleAmount"
            maxlength="15"
            @input="form.singleAmount = onInput(form.singleAmount)"
            :placeholder="$t('common.placeholderContent')">
            <template slot="append">{{$t('common.unit')}}</template>
          </el-input>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.safeAmount')"
          prop="safeAmount"
          class="item-form">
          <el-input v-model="form.safeAmount"
            maxlength="15"
            @input="form.safeAmount = onInput(form.safeAmount)"
            :placeholder="$t('common.placeholderContent')">
            <template slot="append">{{$t('common.unit')}}</template>
          </el-input>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.payOutStartTime')"
          prop="payOutStartTime"
          class="item-form">
          <el-time-picker v-model="form.payOutStartTime"
            :picker-options="{
              maxTime: form.lastPayOutTime
            }"
            :placeholder="$t('common.placeholderSelect')"
            value-format="HH:mm:ss"
            style="width: 100%">
          </el-time-picker>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.lastPayOutTime')"
          prop="lastPayOutTime"
          class="item-form">
          <el-time-picker v-model="form.lastPayOutTime"
            :picker-options="{
              minTime: form.payOutStartTime
            }"
            :placeholder="$t('common.placeholderSelect')"
            value-format="HH:mm:ss"
            style="width: 100%">
          </el-time-picker>
        </el-form-item>

        <el-form-item :label="$t('fundAtp.payOutTotalAmount')"
          prop="payOutTotalAmount"
          class="item-form">
          <el-input v-model="form.payOutTotalAmount"
            maxlength="50"
            @input="form.payOutTotalAmount = onInput(form.payOutTotalAmount)"
            :placeholder="$t('common.placeholderContent')">
            <template slot="append">{{$t('common.unit')}}</template>
          </el-input>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.payOutSingleAmount')"
          prop="payOutSingleAmount"
          class="item-form">
          <el-input v-model="form.payOutSingleAmount"
            maxlength="50"
            @input="form.payOutSingleAmount = onInput(form.payOutSingleAmount)"
            :placeholder="$t('common.placeholderContent')">
            <template slot="append">{{$t('common.unit')}}</template>
          </el-input>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.companyName')"
          prop="companyName"
          class="item-form">
          <el-input v-model="form.companyName"
            maxlength="50"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.userId')"
          prop="userId"
          class="item-form">
          <el-input v-model="form.userId"
            maxlength="50"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.userPassword')"
          prop="userPassword"
          class="item-form">
          <el-input v-model="form.userPassword"
            maxlength="50"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.mobileNumber')"
          prop="mobileNumber"
          class="item-form">
          <el-input v-model="form.mobileNumber"
            maxlength="20"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
        <el-form-item :label="$t('fundAtp.status')"
          class="item-form">
          <el-radio-group v-model="form.status">
            <el-radio v-for="dict in dict.type.bank_account_status"
              :key="dict.value"
              :label="dict.value">{{ dict.label }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item :label="$t('common.remark')"
          class="item-form">
          <el-input v-model="form.remark"
            type="textarea"
            maxlength="200"
            :placeholder="$t('common.placeholderContent')"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer"
        class="dialog-footer">
        <el-button type="primary"
          @click="submitForm">{{$t('common.ok')}}</el-button>
        <el-button @click="cancel">{{$t('common.cancel')}}</el-button>
      </div>
    </el-dialog>

    <!-- 管理员通过/驳回 -->
    <el-dialog :title="$t('fundAtp.adminAudit')"
      :visible.sync="openAdminAudit"
      width="500px"
      append-to-body>
      <el-form ref="formAdminAudit"
        :model="formAdminAudit"
        :rules="rulesAdminAudit"
        label-width="120px">
        <el-form-item :label="$t('fundAtp.auditStatus')"
          prop="auditStatus">
          <el-radio-group v-model="formAdminAudit.auditStatus">
            <el-radio key="1"
              label="1">{{ $t('fundAtp.pass') }}</el-radio>
            <el-radio key="-1"
              label="-1">{{ $t('fundAtp.turnDown') }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.modeType')"
          prop="modeType">
          <el-select v-model="formAdminAudit.modeType"
            :placeholder="$t('common.placeholderSelect')"
            clearable
            style="width: 240px">
            <el-option v-for="dict in dict.type.sys_card_mode_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('fundAtp.auditMsg')"
          prop="auditMsg"
          v-if="formAdminAudit.auditStatus == '-1'">
          <el-input v-model="formAdminAudit.auditMsg"
            type="textarea"
            maxlength="200"
            :placeholder="$t('common.placeholderContent')" />
        </el-form-item>
      </el-form>
      <div slot="footer"
        class="dialog-footer">
        <el-button type="primary"
          @click="submitFormAdminAudit">{{$t('common.ok')}}</el-button>
        <el-button @click="cancelAdminAudit">{{$t('common.cancel')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getFundAccountList,
  fundAccountDetail,
  addFundAccount,
  updateFundAccount,
  delFundAccount,
  changeFundAccountStatus,
  applyAudit,
  adminApplyAudit,
} from "@/api/fundAccount/fundAccountPool.js";
import {
  getBankList,
} from "@/api/fundAccount/bankInfo.js";
import ViewShow from '@/views/components/viewShow.vue'
import { onInput } from '@/utils/util.js'
import { mapGetters } from 'vuex'

export default {
  name: "U",
  dicts: ["bank_account_status", 'sys_card_mode_type', 'audit_status'],
  components: { ViewShow },
  data () {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      accountList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        bankId: null,
        status: null,
        auditStatus: null,
        accountName: null,
        accountNumber: null,
        ifscCode: null,
        companyName: null,
        mobileNumber: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        bankId: [
          { required: true, message: this.$t('common.ruleSelectEmpty'), trigger: "change" },
        ],
        accountName: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        accountNumber: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        ifscCode: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        modeType: [
          { required: true, message: this.$t('common.ruleSelectEmpty'), trigger: "change" },
        ],
        totalAmount: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        singleAmount: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        safeAmount: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        payOutStartTime: [
          { required: true, message: this.$t('common.ruleSelectEmpty'), trigger: "change" },
        ],
        lastPayOutTime: [
          { required: true, message: this.$t('common.ruleSelectEmpty'), trigger: "change" },
        ],
        payOutTotalAmount: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        payOutSingleAmount: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        companyName: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        userId: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        userPassword: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
        mobileNumber: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
      },
      bankList: [],
      bankLoading: false,
      showView: false,
      viewList: [],

      openAdminAudit: false,
      formAdminAudit: {},
      rulesAdminAudit: {
        auditStatus: [
          { required: true, message: this.$t('common.ruleSelectEmpty'), trigger: "change" },
        ],
        modeType: [
          { required: true, message: this.$t('common.ruleSelectEmpty'), trigger: "change" },
        ],
        auditMsg: [
          { required: true, message: this.$t('common.ruleInputEmpty'), trigger: "blur" },
        ],
      }
    };
  },
  computed: {
    ...mapGetters([
      'userInfo'
    ]),
  },
  created () {
    this.getList();
    this.getBankMethod()
  },
  methods: {
    onInput,
    // 更多操作触发
    handleCommand (command, row) {
      switch (command) {
        case "handleView":
          this.handleView(row);
          break;
        case "handleUpdateAuditStatus":
          this.handleUpdateAuditStatus(row);
          break;
        case "handleSysAudit":
          this.handleSysAudit(row);
          break;
        default:
          break;
      }
    },
    // 搜索银行
    getBankMethod () {
      getBankList({
        pageNum: 1,
        pageSize: 100,
        status: 1
      }).then(
        (response) => {
          let bankData = JSON.parse(JSON.stringify(response.rows))
          this.bankList = bankData
        }
      );
    },
    // remoteMethod (query) {
    //   if (query !== '') {
    //     this.bankLoading = true;
    //     getBankList({
    //       pageNum: 1,
    //       pageSize: 10,
    //       bankName: query
    //     }).then(
    //       (response) => {
    //         this.bankList = response.rows;
    //         this.bankLoading = false;
    //       }
    //     );
    //   } else {
    //     this.bankList = [];
    //   }
    // },
    /** 查询列表 */
    getList () {
      this.loading = true;
      getFundAccountList(this.queryParams).then(
        (response) => {
          this.accountList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 查看详情
    handleView (row) {
      this.viewList = []
      fundAccountDetail(row.cardId).then((response) => {
        let statusList = this.dict.type.bank_account_status
        let viewInfo = response.data;
        let showData = ['accountName', 'accountNumber', 'ifscCode', 'bankName', 'modeType', 'totalAmount', 'singleAmount', 'payOutTotalAmount',
          'payOutSingleAmount', 'safeAmount', 'payOutStartTime', 'lastPayOutTime', 'companyName', 'userId', 'userPassword', 'mobileNumber',
          'status']
        let commonData = ['remark', 'createBy', 'createTime', 'updateBy', 'updateTime']

        showData.forEach(item => {
          this.viewList.push({
            type: 'text',
            label: this.$t(`fundAtp.${item}`) + '：',
            value: item == 'status' ? statusList.filter(i => viewInfo[item] == i.value)[0].label : viewInfo[item]
          })
        })
        commonData.forEach(item => {
          this.viewList.push({
            type: 'text',
            label: this.$t(`common.${item}`) + '：',
            value: viewInfo[item]
          })
        })

        setTimeout(() => {
          this.showView = true;
        })
      });
    },
    // 提交审核/撤销审核
    handleUpdateAuditStatus (row) {
      let text = ''
      if (row.auditStatus == '0' || row.auditStatus == '-1') {
        text = this.$t('fundAtp.submitAuditTips')
      } else {
        text = this.$t('fundAtp.withdrawAuditTips')
      }

      this.$modal
        .confirm(text)
        .then(function () {
          return applyAudit({
            cardId: row.cardId,
            auditStatus: (row.auditStatus == '0' || row.auditStatus == '-1') ? '2' : '0'
          });
        })
        .then(() => {
          this.$modal.msgSuccess(this.$t('common.successfulOperation'));
          this.getList();
        })
        .catch(function () {

        });
    },
    // 管理员审核/驳回
    handleSysAudit (row) {
      this.formAdminAudit = {
        cardId: row.cardId,
        auditStatus: null,
        auditMsg: null,
        modeType: row.modeType
      }
      this.resetForm("formAdminAudit");
      this.openAdminAudit = true
    },
    submitFormAdminAudit () {
      this.$refs["formAdminAudit"].validate((valid) => {
        if (valid) {
          adminApplyAudit(this.formAdminAudit).then((response) => {
            this.$modal.msgSuccess(this.$t('common.successfulOperation'));
            this.openAdminAudit = false;
            this.getList();
          });
        }
      });
    },
    cancelAdminAudit () {
      this.openAdminAudit = false
    },
    // 状态修改
    handleStatusChange (row) {
      // let text = row.status === "0" ? "启用" : "停用";
      let text = '';
      let tips = ''
      if (row.status === "1") {
        text = `${this.$t('common.statusChangesEnable')} ${row.accountName} ?`
        tips = this.$t('common.enabledSuccessfully')
      } else {
        text = `${this.$t('common.statusChangesDisable')} ${row.accountName} ?`
        tips = this.$t('common.disableSuccessfully')
      }
      this.$modal
        // .confirm('确认要"' + text + '""' + row.roleName + '"吗？')
        .confirm(text)
        .then(function () {
          return changeFundAccountStatus({
            status: row.status,
            cardId: row.cardId
          });
        })
        .then(() => {
          this.$modal.msgSuccess(tips);
        })
        .catch(function () {
          row.status = row.status === "0" ? "1" : "0";
        });
    },
    // 取消按钮
    cancel () {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset () {
      this.form = {
        bankId: null,
        accountName: null,
        accountNumber: null,
        ifscCode: null,
        modeType: null,
        totalAmount: null,
        singleAmount: null,
        safeAmount: null,
        lastPayOutTime: '17:30:00',
        payOutStartTime: '08:30:00',
        payOutTotalAmount: '',
        payOutSingleAmount: '',
        companyName: null,
        userId: null,
        userPassword: null,
        mobileNumber: null,
        status: '1',
        remark: null
      };
      // this.bankList = []
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery () {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery () {
      this.resetForm("queryForm");
      this.queryParams.bankId = ''
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange (selection) {
      this.ids = selection.map((item) => item.cardId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

    /** 新增按钮操作 */
    handleAdd () {
      this.reset();
      this.open = true;
      this.title = this.$t('fundAtp.addAccount');
    },
    /** 修改按钮操作 */
    handleUpdate (row) {
      this.reset();
      const cardId = row.cardId || this.ids;
      fundAccountDetail(cardId).then((response) => {
        this.form = response.data;
        // this.bankList = [{
        //   bankName: this.form.bankName,
        //   bankId: this.form.bankId
        // }]
        this.open = true;
        this.title = this.$t('fundAtp.editAccount');
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.cardId != undefined) {
            updateFundAccount(this.form).then((response) => {
              this.$modal.msgSuccess(this.$t('common.editSuccessfully'));
              this.open = false;
              this.getList();
            });
          } else {
            addFundAccount(this.form).then((response) => {
              this.$modal.msgSuccess(this.$t('common.newSuccess'));
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete (row) {
      const cardIds = row.cardId || this.ids;
      this.$modal
        // .confirm('是否确认删除银行id为"' + cardIds + '"的数据项？')
        .confirm(this.$t('common.deleteDataTips'))
        .then(function () {
          return delFundAccount(cardIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess(this.$t('common.successfullyDeleted'));
        })
        .catch(() => { });
    }
  },
};
</script>

<style lang="scss" scoped>
.form-box {
  display: flex;
  flex-wrap: wrap;
  .item-form {
    width: 50%;
  }
}
</style>